open Base
open Math

type tree and t = tree

type dir = [`H | `V]
type fig = Rect of Dim.t * Color.t

val uninit : t
val arm : dir -> t list -> t
val figure : fig -> t

val equal : t -> t -> bool
val to_string : t -> string
val is_init : t -> bool
val event_ids : t -> Event.Id.t Sequence.t

module Path : sig
  type t
  val root : unit -> t
  val of_list : int list -> t
  val of_list_rev : int list -> t
  val to_list : t -> int list
  val to_string : t -> string
  val equal : t -> t -> bool
end

val path : t -> Path.t
val refresh_paths : ?rev_prefix:int list -> t -> unit

module Update : sig
  type t = Set of fig | Mount of tree | Unmount
  val equal : t -> t -> bool
  val to_string : t -> string
end

type updates = (Path.t * Update.t) Sequence.t
val apply_updates_exn : updates -> tree -> tree

module Draw : sig
  type t = Rect of AABB.t * Color.t
  val equal : t -> t -> bool
  val to_string : t -> string
end

val render : tree -> Draw.t Sequence.t
val capture_point : pos:Pos.t -> tree -> Event.Id.t option
